/**
 * This class contains unit tests for validating the behavior of Apex classes
 * and triggers.
 *
 * Unit tests are class methods that verify whether a particular piece
 * of code is working properly. Unit test methods take no arguments,
 * commit no data to the database, and are flagged with the testMethod
 * keyword in the method definition.
 *
 * All test methods in an organization are executed whenever Apex code is deployed
 * to a production organization to confirm correctness, ensure code
 * coverage, and prevent regressions. All Apex classes are
 * required to have at least 75% code coverage in order to be deployed
 * to a production organization. In addition, all triggers must have some code coverage.
 * 
 * The @isTest class annotation indicates this class only contains test
 * methods. Classes defined with the @isTest annotation do not count against
 * the organization size limit for all Apex scripts.
 *
 * See the Apex Language Reference for more information about Testing and Code Coverage.
 */
@isTest
private class Test_buttonExecutionClass 
{
    static testMethod void myUnitTest() 
    {
        // TO DO: implement unit test
    	Account account = new Account();
	    account.Name = 'Ahmed Adel' ;
	    insert account ;
	      
	    Opportunity opportunity = new Opportunity();
	    opportunity.AccountId = account.id ;
	    opportunity.StageName = 'Prospecting' ;
	    opportunity.CloseDate = system.Today();
	    opportunity.Name = 'test' ;
	    insert opportunity ;
	      
	    Pricebook2 pb = [select id from Pricebook2 where IsStandard = true limit 1];
	    
	    Product2 p = new Product2();
	    p.Name = 'Test Product' ;
	    insert p ;
	      
	    PricebookEntry pbe = new PricebookEntry(UnitPrice = 90);
	    pbe.Pricebook2Id = pb.id ;
	    pbe.Product2Id = p.Id ;      
	    pbe.UseStandardPrice = false ;
	    pbe.IsActive = true ;
	    insert pbe ;
	      
	    OpportunityLineItem l1 = new OpportunityLineItem();
	    l1.OpportunityId = opportunity.id ;
	    l1.Quantity = 90 ;
	    l1.TotalPrice = 890 ;
	    l1.PricebookEntryId = pbe.Id ;
	    insert l1 ;
		
		
		OpportunityLineItem l2 = new OpportunityLineItem();
	    l2.OpportunityId = opportunity.id ;
	    l2.Quantity = 90 ;
	    l2.TotalPrice = 890 ;
	    l2.PricebookEntryId = pbe.Id ;
	    insert l2;
	    
	    //Now Delete the Opportunity Line Item to trigger After delete Event....
	    delete l2;
	    
	    
		
		Contact contact1 = new Contact(Email = 'test@CC.com' , Fax = '1212' , Phone = '23232');
     	contact1.FirstName = 'Ahmed' ;
      	contact1.LastName = 'Ahmed1' ;
      	insert contact1 ;
      
      	Quote quote = new Quote();
      	quote.name = 'test' ;
      	quote.OpportunityId = opportunity.id ;
      	quote.Pricebook2Id = pb.id;
      	quote.ContactId = contact1.id ;
      	insert quote;
      	
      	QuoteLineItem quoteItemObject = new QuoteLineItem();
      	quoteItemObject.Quantity = 2;
      	quoteItemObject.QuoteId = quote.Id;
      	quoteItemObject.PricebookEntryId = pbe.id;
        quoteItemObject.UnitPrice = 265;
        quoteItemObject.Item_Number__c = 1;
        insert quoteItemObject;
      	
      	
      	QuoteLineItem quoteItemObject1 = new QuoteLineItem();
      	quoteItemObject1.Quantity = 2;
      	quoteItemObject1.QuoteId = quote.Id;
      	quoteItemObject1.PricebookEntryId = pbe.id;
        quoteItemObject1.UnitPrice = 265;
        quoteItemObject1.Item_Number__c = 1;
        insert quoteItemObject1;
        
        
        
        //For Delete Quote Line Item For Trigger...
        delete quoteItemObject1;
        
        
      	//Now Calling the Button Execution Class...
      	string result = buttonExecutionClass.quoteItemSortMethod(quote.Id);
      	result = buttonExecutionClass.oppItemSortMethod(opportunity.Id);
      	
      	        
        
    }
}